package br.trainee.web.util;

import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

//wrapper que recebe o response enviado do tag handler, herda um wrapper de response pois é necessario sobrescrever alguns metodos
public class ResponseWrapper extends HttpServletResponseWrapper{

	
	private CharArrayWriter saida;
	
	{
		saida = new CharArrayWriter();
	}
	
	public ResponseWrapper(HttpServletResponse response) {		
		
		super(response);
		// TODO Auto-generated constructor stub
		
	}
	
	//sobrescreve o printwriter do HttpServletResponseWrapper do pai
	@Override
	public PrintWriter getWriter() throws IOException {
		
		return new PrintWriter(saida);
	}
	
	//pega a saida em formato string para ser passado par ao tag handler
	public String getString(){
		
		return saida.toString();
	}

}
